package com.jzo2o.customer.mapper;

import com.jzo2o.customer.model.domain.AddressBook;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 地址薄 Mapper 接口
 * </p>
 *
 * @author itcast
 * @since 2023-07-06
 */
@Mapper
public interface AddressBookMapper extends BaseMapper<AddressBook> {

    @Select("SELECT * from address_book WHERE user_id = ( SELECT user_id from address_book WHERE id = #{id}) and is_deleted = 0")
    List<AddressBook> selectListById(Long id);

    @Select("select * from address_book where user_id = #{id} and is_default = 1 and is_deleted = 0")
    AddressBook getDefaultAddress(Long id);
}
